package bdpan

import (
	"awesomeProject/crawler/engine"
	"awesomeProject/crawler/fetcher"
)

/**
  Work() contains three modules:
     1. Download from the url
     2. Parse the string downloaded
     3. handle the data parsed (output,savefile etc.)
  My design is to avoid handling data in engine
  in order to make the program more extendable
*/

func Work(url string) engine.WorkResult {
	body := fetcher.Download(url)
	urls := GetUrl(body)
	links := GetPanLink(body)
	var result engine.WorkResult
	//var reqs []engine.Request
	for _, u := range urls {
		result.Requests = append(result.Requests, engine.Request{
			Url:    u,
			Worker: Work,
		})
	}
	for _, link := range links {
		result.Items = append(result.Items, link)
	}
	return result
}

func HandleResult(items []interface{}) {

}

func AllDone() {

}
